package helper;

import java.sql.Connection;
import java.sql.DriverManager;
public class DataSource {
    static java.sql.Connection connection = null;
    public static Connection getConnection() {
        try {
            if (connection == null) {
                Class.forName("org.apache.derby.jdbc.ClientDriver");
                String url="jdbc:derby://127.0.0.1:1527/BBS";
                connection=DriverManager.getConnection(url,"sa","123456");
                System.out.println("连接成功！");
                return  connection;
            } else {
                return connection;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

}
